﻿@page
@inject ISimpleLocalizer SimpleLocalizer
@using LocalizeMessagesAndErrors
@using Microsoft.AspNetCore.Mvc.TagHelpers
@model Example1.RazorPages.IndividualAccounts.Pages.AuthRoles.ListRolesModel

<h1>Manage roles</h1>

@if (!string.IsNullOrEmpty(Model.Message))
{
    <h3 class="text-primary">@Model.Message</h3>
}

<a class="btn btn-primary" asp-area="" asp-page=".\Create">
    @SimpleLocalizer.LocalizeString("Create new role", this)
</a>
<p></p>

<table class="table">
    <thead>
        <tr>
            <th>
                @SimpleLocalizer.LocalizeString("Role Name", this)
            </th>
            <th>
                @SimpleLocalizer.LocalizeString("Description", this)
            </th>
            <th>
                #@SimpleLocalizer.LocalizeString("Permissions", this)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.AuthRolesList)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.RoleName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Description)
                </td>
                <td>
                    <a href="#" data-toggle="tooltip" title='@string.Join(", ",item.PermissionNames)'>
                        @item.PermissionNames.Count
                    </a>
                </td>
                <td>
                    <!--This should have User.HasPermission(Example4Permissions.RoleChange around them-->
                    <a asp-area="" asp-page=".\Edit" asp-route-rolename="@item.RoleName">
                        @SimpleLocalizer.LocalizeString("Edit", this)
                    </a>
                    |
                    <a asp-area="" asp-page=".\Delete" asp-route-rolename="@item.RoleName">
                        @SimpleLocalizer.LocalizeString("Delete", this)
                    </a>
                </td>
            </tr>
        }
    </tbody>
</table>

@section Scripts{


    <script type='text/javascript'>
        $(function () {
            $('[data-toggle="tooltip"]').tooltip();
        })
    </script>
}